<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        .center{
            width: 1200px;
            margin: 0 auto;
        }
        #footer_center p{
            margin: 0;
        }
        #footer_center h3{
            color: white;
        }
    </style>
</head>
<body>
<div id="app">
    <el-container>
        <my-header></my-header>
        <el-main class="center" style="margin-top: 30px">
            <el-row gutter="20">
                <el-col span="12">
                    <el-card>
                        <img src="imgs/reg.png" width="100%">
                    </el-card>
                </el-col>
                <el-col span="12">
                    <!--注册表单开始-->
                    <el-form label-width="80px">
                        <el-form-item>
                            <h1 style="float: left;font-size: 28px">立即注册</h1>
                            <a style="float: right;
                            text-decoration: none;color: #409EFF;
                            position: relative;top: 20px"  href="login.html">
                                已有账号?现在登录
                            </a>
                        </el-form-item>
                        <el-form-item label="用户名">
                            <el-input placeholder="请输入用户名" v-model="user.userName"></el-input>
                        </el-form-item>
                        <el-form-item label="密码">
                            <el-input placeholder="请输入密码" v-model="user.password"></el-input>
                        </el-form-item>
                        <el-form-item label="昵称">
                            <el-input placeholder="请输入昵称" v-model="user.nickName"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="reg()">注册</el-button>
                        </el-form-item>
                    </el-form>
                    <!--注册表单结束-->
                </el-col>
            </el-row>

        </el-main>
        <el-footer style="height: 280px;background-color: #2f3234;padding:50px 0">
          <my-footer></my-footer>

        </el-footer>
    </el-container>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<!--引入Axios-->
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
<!--引入自己的js文件-->
<script src="js/my-header.js"></script>
<script src="js/my-footer.js"></script>

<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                user:{userName:"",password:"",nickName:""}
            }
        },
        methods: {
            reg(){
                axios.post("/v1/users/reg",v.user).then(function (response) {
                    if (response.data.code==1){
                        location.href="/";
                    }else{
                        v.$message.error(response.data.msg);
                    }
                })
            }
        }
    })
</script>
</html>